package Classes.GameUtils
{
	import Classes.GameDatas.GD_Player;
	import Classes.Managers.M_ConfigData;

	/** 
	 * @author thy
	 * @version 1.0.0 
	 * 创建时间：Jun 7, 2012 3:05:29 PM 
	 */ 
	public class GU_NewThingsControler
	{
		private var imgPath:String;
		public function GU_NewThingsControler(newThingsObj:Object)
		{
			if(newThingsObj)
			{
				var date:Date=new Date();
				var newMsg:String = newThingsObj.title;
				var sayTxt:String=newThingsObj.saytxt;
				var newcontext:String=newThingsObj.context;
				//替换名字
				while(newcontext.indexOf("@userName")!=-1)
				{
					newcontext=newcontext.replace("@userName",GD_Player.instance.playerName);
				}
				//替换等级
				while(newcontext.indexOf("@userLv")!=-1)
				{
					newcontext=newcontext.replace("@userLv",GD_Player.instance.playerLv);
				}
				var desMsg:String = newcontext+"("+date.getHours()+"："+date.getMinutes()+")";
				imgPath = newThingsObj.img;
				if(imgPath.indexOf("http") == -1)
				{
					imgPath =M_ConfigData.instance.imgUrl+newThingsObj.img;
				}
				
				if(M_ConfigData.instance.isPlatformProviderFeed)
				{
					//修改模式
					M_ConfigData.instance.changeParams("transparent");
					platformProviderFeed(newMsg,desMsg,imgPath,sayTxt);
				}else{
					//调用自己的
				}
			}
		}
		
		/**
		 * 平台自带feed 
		 */		
		public function platformProviderFeed(newMsg:String,desMsg:String,imgPath:String,sayTxt:String):void{
			var feedObj:Object = {template_bundle_id: 1,
				template_data:{images:[{src:imgPath, href:""}],title:newMsg,content:desMsg,sayTxt:sayTxt}};
			M_ConfigData.instance.feedFunc(feedObj);
		}
	}
}
